package com.UnionPayCenter.coupon.service.impl;

import com.UnionPayCenter.coupon.dto.CouponChangeValidDTO;
import com.UnionPayCenter.coupon.manager.CouponManager;
import com.UnionPayCenter.coupon.service.CouponOperatorService;
import com.UnionPayCenter.entity.CouponEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author noah
 * @since 1.0.0, 2019/09/20
 */
@Service
public class CouponOperatorServiceImpl implements CouponOperatorService {

    @Autowired
    CouponManager couponManager;

    @Override
    public void changeCouponValidTag(CouponChangeValidDTO changeValidDTO) {
        CouponEntity couponEntity = couponManager.couponQuery(changeValidDTO.getDisTypeId());
        if(Objects.isNull(couponEntity)){
            return;
        }
        couponEntity.setValidTag(changeValidDTO.getValidTag());
        couponManager.couponUpdate(couponEntity);

    }
}
